function meanM2 = model_meanM2(beta,t,model)
nu = beta(1);
sigma2 = beta(2);

meanM2 = zeros(length(t),1);
for i = 1:length(t)
    meanAlpha2 = zeros(1,model.mode);
    meanBeta2  = zeros(1,model.mode);
    for j = 1:model.mode
        temp  = sigma2/(2*nu*j^2);
        temp2 = exp(-2*nu*t(i)*j^2);
        meanAlpha2(j) = temp+(meanAlpha2(j)-temp)*temp2;
        meanBeta2(j)  = temp+(meanBeta2(j)-temp)*temp2;
    end
    meanM2(i) = sum(meanAlpha2'.*model.M2ModeWeighting(:,1)+meanBeta2'.*model.M2ModeWeighting(:,2))/(2*model.SiteNum);
end
end


